﻿@model WebUI.Models.aspnet_Users
<style type="text/css">
    table.thistable tr td
    {
        padding-top: 0px;
        padding-bottom: 0px;
    }
    
    .tabheader a
    {
        min-width: 80px;
        padding: 4px;
        margin: 1px;
        background-color: #f19149;
        border: 1px solid #f1f1f1;
        color: White;
        white-space: nowrap;
        text-decoration: none;
        line-height: 24px;
    }
</style>
@using (Ajax.BeginForm(new AjaxOptions()
{
    LoadingElementId = "OnLoadingSpan",
    UpdateTargetId = "dialogbox",
    InsertionMode = InsertionMode.Replace,
    HttpMethod = "Post",
    OnSuccess = "alert('保存成功，请继续其他操作。')",
    OnFailure = "OnSiteError"
        ,
    OnBegin = "$('#submit').fadeOut(500)"
        ,
    OnComplete = "$('#submit').fadeIn(1000)"
}))
{//OnSuccess = "$('#dialogbox').dialog('close');",
    @Html.ValidationSummary(true)
    <table class="width noborder tabheader " title="切换前请一定注意是否有未保存数。">
        <tr>
            <td width="64px" nowrap="nowrap" valign="top">
                @Ajax.ActionLink("基本信息", "RecuperEdit", new { ID = Model.UserId }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "dialogbox", Confirm = "" }, new { style = "background-color:red;" })
            </td>
            <td valign="top">
                @if (Model.UserId != Guid.Empty && Model.UserAllRecupers.Count < 1)
                {
                    <script type="text/javascript">
                        $(function () {
                            alert("患者需要有住院信息才有效，关闭退出前请添加住院信息。");
                        });
                    </script>
                }
                @{var i = 0;}
                @foreach (var rec in Model.UserAllRecupers.OrderByDescending(v => v.EnHospDay))
                {
                    var bbr = (i % 3) == 2;
                    i++;

                    if (rec.DepartmentID == SiteUser.DepartmentID || ViewBag.Flag == "Recuper")
                    {
                    @Ajax.ActionLink(rec.EnHospDay.ToString("yy年M月") + "-" + rec.Hospital.HospCode, "RecuperEnHospEdit", new { ID = rec.RecuperID }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "dialogbox", Confirm = "" })
                    }
                    else
                    {
                    <a href="#" style="color: #aaaaaa;">@(rec.EnHospDay.ToString("yy年M月") + "-" + rec.Hospital.HospCode)</a>
                    }


                    if (bbr)
                    { 
                    <br />
                    }
                }
            </td>
            @if (ViewBag.Flag != "Recuper")
            {
                <td align="right" width="88" nowrap="nowrap" valign="top">
                    @if (SiteUser.IsDoctorDepManager && Model.UserId != Guid.Empty)
                    {
                        @Ajax.ActionLink("+录入住院信息", "RecuperEnHospEdit", new { ID = string.Empty, UserID = Model.UserId }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "dialogbox", Confirm = "" })
                    }
                </td>
            }
        </tr>
    </table>
    <fieldset>
        @Html.HiddenFor(model => model.UserId)
        <table class="width noborder thistable tiny" cellpadding="0" cellspacing="0" style="padding-top: 0px;
            padding-bottom: 0px;">
            <col width="15%" />
            <col width="15%" />
            <col width="35%" />
            <col width="35%" />
            <tr>
                <td colspan="2">@Html.EditorFor(model => model.UserName, "TxtField")
                </td>
                <td>
                    <div class="editor-label">
                        <span style="color: Red">*</span> 密码</div>
                    <div class="editor-field">@Html.TextBox("Pwd", null, new { title = "新建或修改密码时才需填写,新建时如未填写，会尝试用病案号作为密码。" })</div>
                </td>
                @* <td>                    <div class="editor-label">
                        @Html.LabelFor(model => model.Department.DepName)</div>
                    <div class="editor-field">
                        @Html.HiddenFor(model => model.DepartmentID)
                        @Html.TextBoxFor(model => model.Department.DepName, new { disabled = true })
                    </div>
                </td>*@
                <td>@Html.EditorFor(model => model.SheBaoHao, "TxtField")
                </td>
            </tr>
            <tr>
                <td colspan="2">@Html.EditorFor(model => model.MobileAlias, "TxtField")
                </td>
                <td>@Html.EditorFor(model => model.HomePhone, "TxtField")
                </td>
                <td>@Html.EditorFor(model => model.OtherPhone, "TxtField")
                </td>
            </tr>
            <tr>
                <td colspan="2">@Html.EditorFor(model => model.MobileAliasB, "TxtField")
                </td>
                <td>@Html.EditorFor(model => model.HomePhoneB, "TxtField")
                </td>
                <td>@Html.EditorFor(model => model.OtherPhoneB, "TxtField")
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table class="tiny-input2">
                        <tr>
                            <td>@Html.EditorFor(model => model.Gender, "SelField", new { Selects = new SelectList(",男,女".Split(','), Model.Gender) })
                            </td>
                            <td>
                                &nbsp;&nbsp;
                            </td>
                            <td>
                                <div class="editor-label">
                                    <label>
                                        年龄</label>
                                </div>
                                <div class="editor-field">
                                    <input type="text" disabled="disabled"
                                    value="@Helpers.GetAgeRaw(Model.BirthDay)"
                                     />
                                    <span class="field-validation-valid"></span>
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
                <td>
                    <table class="tiny-input2">
                        <tr>
                            <td>@Html.EditorFor(model => model.UserHeight, "TxtField")
                            </td>
                            <td>
                                &nbsp;&nbsp;
                            </td>
                            <td>@Html.EditorFor(model => model.UserWeight, "TxtField")
                            </td>
                        </tr>
                    </table>
                </td>
                <td>@Html.EditorFor(model => model.HuanZheLaiYuan, "TxtField")
                </td>
            </tr>
            <tr>
                <td colspan="2">@Html.EditorFor(model => model.IDCodeType, "SelField", new { Selects = new SelectList("身份证,士官证,学生证,驾驶证,护照,港澳通行证,其他证件".Split(','), Model.IDCodeType) })
                </td>
                <td>
                    @Html.EditorFor(model => model.IDCode, "TxtField")
                </td>
                <td>@Html.EditorFor(model => model.BirthDay, "TxtField")
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    @Html.EditorFor(model => model.PostCode, "TxtField")
                </td>
                <td>
                    &nbsp;
                </td>
                <td>@Html.EditorFor(model => model.Email, "TxtField")
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    <div class="editor-label">
                        @Html.LabelFor(model => model.Address)
                    </div>
                    <div class="editor-field">
                        @Html.TextBoxFor(model => model.Address, new { style = "width:90%" })
                    </div>
                </td>
            </tr>
        </table>
        <p>
            @if (ViewBag._ReadOnly == true)
            {
                <input type="button" disabled="disabled" value="确定" />
            }
            else if (SiteUser.IsDoctorDepManager || Model.UserId == SiteUser.UserId)
            {
                <input type="submit" value="确定" />
            }
        </p>
    </fieldset>
}
